<?php
//=======================================
//###################################
// Kayako Web Solutions
//
// Source Copyright 2001-2004 Kayako Web Solutions
// Unauthorized reproduction is not allowed
// License Number: $%LICENSE%$
// $Author: mslaria $ ($Date: 2007/03/30 11:43:36 $)
// $RCSfile: downloads.php,v $ : $Revision: 1.10 $ 
//~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
//
//###################################
//=======================================

if (!defined("INSWIFT")) {
	trigger_error("Unable to process $PHP_SELF", E_USER_ERROR);
}

/**
* Downloads Module
*/
class downloads {

	/**
	* Constructor to register any events, sections
	*/
	function downloads() {
		global $_SWIFT, $events;

		$events->registerEventModuleSWIFT(MODULE_DOWNLOADS, $this);

		// Staff CP
		$events->registerEvent(EVENT_STAFF, MODULE_DOWNLOADS, "managecategories");
		$events->registerEvent(EVENT_STAFF, MODULE_DOWNLOADS, "managefiles");
		$events->registerEvent(EVENT_STAFF, MODULE_DOWNLOADS, "insertcategory");
		$events->registerEvent(EVENT_STAFF, MODULE_DOWNLOADS, "editcategory");
		$events->registerEvent(EVENT_STAFF, MODULE_DOWNLOADS, "insertfile");
		$events->registerEvent(EVENT_STAFF, MODULE_DOWNLOADS, "editfile");
		$events->registerEvent(EVENT_STAFF, MODULE_DOWNLOADS, "comments");
		$events->registerEvent(EVENT_STAFF, MODULE_DOWNLOADS, "reports");
		$events->registerEvent(EVENT_STAFF, MODULE_DOWNLOADS, "downloadfile");

		// Support Center
		$events->registerEvent(EVENT_CLIENT, MODULE_DOWNLOADS, "view");
		$events->registerEvent(EVENT_CLIENT, MODULE_DOWNLOADS, "viewdownload");
		$events->registerEvent(EVENT_CLIENT, MODULE_DOWNLOADS, "downloadfile");

		// RSS
		$events->registerEvent(EVENT_RSS, MODULE_DOWNLOADS, "view");

		$eventaction = $events->eventdata["eventaction"];
	}

	/**
	* Destructor, called to unregister any events etc
	*/
	function _downloads() {
	}

	/*
	* Call back function
	*/
	function _eventcallback($eventtype, $eventaction)
	{
		global $_SWIFT, $interface, $template, $departments, $staffauth, $module, $grid, $xml, $staff, $settings, $dbCore, $events, $session, $loginshare, $cookie, $errormessage, $infomessage, $permissions, $mimelist;

		if ($eventtype == EVENT_STAFF && ($eventaction == "managecategories" || $eventaction == "managefiles" || $eventaction == "insertcategory" || $eventaction == "insertfile" || $eventaction == "editfile" || $eventaction == "editcategory" || $eventaction == "downloadfile")) {
			require_once ("./modules/downloads/staff_downloads.php");
			return true;
		} else if ($eventtype == EVENT_STAFF && ($eventaction == "reports")) {
			require_once ("./modules/downloads/staff_reports.php");
			return true;
		} else if ($eventtype == EVENT_STAFF && ($eventaction == "comments")) {
			require_once ("./modules/downloads/staff_comments.php");
			return true;
		} else if ($eventtype == EVENT_CLIENT && ($eventaction == "view" || $eventaction == "viewdownload" || $eventaction == "downloadfile")) {
			require_once ("./modules/downloads/client_downloads.php");
			return true;
		} else if ($eventtype == EVENT_RSS && ($eventaction == "view")) {
			require_once ("./modules/downloads/rss_view.php");
			return true;
		}
		

		return false;
	}
}
?>